import instance from '@/http/index'
import type {publishMessageForm,editMessageForm,companyMessageListForm} from './type'
//统一管理接口
enum API {
   publishMessage_url = '/msg/publishMessage',
   companyMessageList_url = '/msg/companyMessageList',
   systemMessageList_url = '/msg/systemMessageList',
   editMessage_url = '/msg/editMessage',
   searchMessageBydepartment_url = '/msg/searchMessageByDepartment',
   searchMessageByLevel_url = '/msg/searchMessageByLevel',
   getMessage_url = '/msg/getMessage',
   updateClick_url = '/msg/updateClick',
   firstDelete_url = '/msg/firstDelete',
   recycleList_url = '/msg/recycleList',
   getRecycleMessageLength_url = '/msg/getRecycleMessageLength',
   returnRecycleListData_url = '/msg/returnRecycleListData',
   recover_url = '/msg/recover',
   deleteMessage_url = '/msg/deleteMessage',
   getCompanyMessageLength_url = '/msg/getCompanyMessageLength',
   getSystemMessageLength_url = '/msg/getSystemMessageLength',
   returnCompanyListData_url = '/msg/returnCompanyListData',
   returnSystemListData_url = '/msg/returnSystemListData'
}

// 发布消息
export const publishMessage =  (data:publishMessageForm) => {
    return  instance.post(API.publishMessage_url,data)
}
// 获取公司公告列表
export const companyMessageList = (data:companyMessageListForm) => {
    return instance.post(API.companyMessageList_url,data)
}

// 获取系统消息列表
export const systemMessageList = () => {
    return instance.post(API.systemMessageList_url)
}

// 编辑公告
export const editMessage = (data:editMessageForm) => {
    return instance.post(API.editMessage_url,data)
}

// 根据发布部门进行获取消息
export const searchMessageBydepartment = (message_publish_department:string) => {
    return instance.post(API.searchMessageBydepartment_url,{message_publish_department})
}

// 根据发布等级进行获取消息
export const searchMessageByLevel = (message_level:string) => {
    return instance.post(API.searchMessageByLevel_url,{message_level})
}
// 获取公告/系统消息
export const getMessage = (id:number) => {
    return instance.post(API.getMessage_url,{id})
}

// 更新点击率
export const updateClick = (message_click_number:number, id:number) => {
    return instance.post(API.updateClick_url,{message_click_number,id})
}

// 初次删除
export const firstDelete = (id:number) => {
    return instance.post(API.firstDelete_url,{id})
}

// 获取回收站的列表
export const recycleList = () => {
    return instance.post(API.recycleList_url)
}

// 获取回收站总数
export const getRecycleMessageLength = () => {
    return instance.post(API.getRecycleMessageLength_url)
}

// 监听换页返回数据  回收站列表
export const returnRecycleListData = (pager:number) => {
    return instance.post(API.returnRecycleListData_url,{pager})
}


// 还原操作
export const recover = (id:number) => {
    return instance.post(API.recover_url,{id})
}

// 删除操作
export const deleteMessage = (id:number) => {
    return instance.post(API.deleteMessage_url,{id})
}

// 获取公司公告总数
export const getCompanyMessageLength = () => {
    return instance.post(API.getCompanyMessageLength_url)
}

// 获取系统消息总数
export const getSystemMessageLength = () => {
    return instance.post(API.getSystemMessageLength_url)
}

// 监听换页返回数据  公司公告列表
export const returnCompanyListData = (pager:number) => {
    return instance.post(API.returnCompanyListData_url,{pager})
}

// 监听换页返回数据  系统消息列表
export const returnSystemListData = (pager:number) => {
    return instance.post(API.returnSystemListData_url,{pager})
}